using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

namespace CAIR.Lib
{
    public class E1EnergyFunction : IEnergyFunction
    {
        #region IEnergyFunction Members

        public double GetEnergyAt(Bitmap bitmap, int row, int column)
        {
            // TODO: check boundaries.
            int e1 = bitmap.GetPixel(column, row).ToArgb();
            int e2x = e1;
            if (column + 1 < bitmap.Width)
                e2x = bitmap.GetPixel(column + 1, row).ToArgb();
            int e2y = e1;
            if (row + 1 < bitmap.Height)
                e2y = bitmap.GetPixel(column, row + 1).ToArgb();

            return Math.Abs(e1 - e2x) + Math.Abs(e1 - e2y);
        }

        #endregion
    }
}
